<%-- 
    Document   : doLogin
    Created on : 3/04/2011, 10:33:06 AM
    Author     : Jhon
--%>


<%@page import="vo.VOUser"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="control.Controller"%>
<%
boolean roll;


String handle = request.getParameter("handle");
String paswd = request.getParameter ("paswd");

if(handle!=null && paswd!=null){

Controller c = Controller.getInstance();
boolean logg= false;
try{
    logg = c.login(handle,paswd);
    
}catch(Exception e){
    session.setAttribute("ERROR", e.getMessage());
    response.sendRedirect("index.jsp");
    return ;
    }


if(logg){
VOUser a = c.findUser(handle);
if(a.isIsAdmin()){
    
    session.setAttribute("USER",a);
    response.sendRedirect("../Administrator/AdminIndex.jsp");
    }
else{
    
    session.setAttribute("USER",a);
    response.sendRedirect("../User/UserIndex.jsp");
    }
}else{
    session.setAttribute("ERROR", "Handle/Password doesn't match");
    response.sendRedirect("index.jsp");
}


}else{
    response.sendRedirect("index.jsp");
}
%>
